package huniqid

import (
	gonanoid "github.com/matoous/go-nanoid/v2"
)

type Option struct {
	Alphabet string `json:"alphabet"` // 可用字符集,用于生成哈希字符串
	Length   int    `json:"length"`   // 输出哈希ID的期望长度
}

func NewOption() *Option {

	return &Option{
		Alphabet: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
		Length:   6,
	}
}

func (o *Option) Uniqid() (uniqid string, err error) {

	uniqid, err = gonanoid.Generate(o.Alphabet, o.Length)
	return
}
